package com.example.demo.dao;

import com.example.demo.model.Remark;
import com.example.demo.model.vo.RemarkVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RemarkMapper {

    // 查询评论列表根据文章id
    @Select("select r.*,u.nickname from remark r left join userinfo u on r.uid\n" +
            "=u.uid where aid=#{aid} order by rid desc")
    List<RemarkVO> getList(@Param("aid")Integer aid);

    // 添加评论
    @Insert("insert into remark(uid,content,aid) " +
            "values(#{uid},#{content},#{aid})")
    int add(Remark remark);

    // 删除评论
    @Delete("delete from remark where rid=#{rid}")
    int del(@Param("rid")Integer rid);

}
